package com.example.network.demos.tcp.utils;

import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.example.network.demos.config.NetworkConfig;
import com.example.network.demos.tcp.domain.TCPMessage;


public class DockingUtils {

    public static TCPMessage postForTCP(TCPMessage message){
        String json = JSON.toJSONString(message);
        String body = HttpRequest.post(NetworkConfig.getNetworkIP() + "/receive/tcp")
                .body(json)
                .execute().body();
        return JSONObject.parseObject(body, TCPMessage.class);
    }

}
